package com.ysg.widget.dialog.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.ysg.R;
import com.ysg.http.data.entity.mine.SignEntity;

public class SignAdapter extends BaseQuickAdapter<SignEntity, BaseViewHolder> {
    private String todaySigned = "0";
    private String onDay = "0";
    
    public SignAdapter() {
        super(R.layout.item_sign);
    }

    public void setData(String todaySigned,String onDay ){
        this.todaySigned = todaySigned;
        this.onDay = onDay;
    }

    @Override
    protected void convert(BaseViewHolder holder, SignEntity item) {

        TextView tv_day = holder.getView(R.id.tv_day);
        RelativeLayout back_sigin = holder.getView(R.id.re_bg);
        ImageView ivSignIn = holder.getView(R.id.ivSignIn);
        ImageView ivIcon = holder.getView(R.id.iv_icon);
        TextView tvUnit = holder.getView(R.id.tvUnit);
        TextView tv_add = holder.getView(R.id.tv_money);


        tv_day.setText("第" + item.getDay() + "天");
        int position = holder.getAbsoluteAdapterPosition();

        if (position == 6) {
            ivIcon.setImageResource(R.mipmap.ic_gift);
            tv_add.setText("超级大礼包");
        } else {
            holder.getView(R.id.ivGift).setVisibility(View.GONE);
            tv_add.setText("钻石+" + item.getGiveDiamonds());
        }

        if (todaySigned.equals("1")) {//已签到
            if (Double.parseDouble(onDay) == 1) {
                if (position == 0) {
                    tv_day.setBackgroundResource(R.mipmap.tv_signied_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_sign);
                    ivIcon.setImageResource(R.mipmap.mine_sign_in);
                    ivSignIn.setVisibility(View.VISIBLE);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.white));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.white));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.white));
                }
            } else if (Double.parseDouble(onDay) == 2) {
                if (position < 1) {
                    ivSignIn.setVisibility(View.VISIBLE);
                    tv_day.setBackgroundResource(R.mipmap.tv_signir_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_un_sign);
                    ivIcon.setImageResource(R.mipmap.mine_un_sign_in);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.grayLightColor));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.grayDirkColor));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.grayColor));
                } else if (position == 1) {
                    tv_day.setBackgroundResource(R.mipmap.tv_signied_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_sign);
                    ivIcon.setImageResource(R.mipmap.mine_sign_in);
                    ivSignIn.setVisibility(View.VISIBLE);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.white));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.white));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.white));
                }
            } else if (Double.parseDouble(onDay) == 3) {
                if (position < 2) {
                    ivSignIn.setVisibility(View.VISIBLE);
                    tv_day.setBackgroundResource(R.mipmap.tv_signir_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_un_sign);
                    ivIcon.setImageResource(R.mipmap.mine_un_sign_in);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.grayLightColor));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.grayDirkColor));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.grayColor));
                } else if (position == 2) {
                    tv_day.setBackgroundResource(R.mipmap.tv_signied_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_sign);
                    ivIcon.setImageResource(R.mipmap.mine_sign_in);
                    ivSignIn.setVisibility(View.VISIBLE);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.white));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.white));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.white));
                }
            } else if (Double.parseDouble(onDay) == 4) {
                if (position < 3) {
                    ivSignIn.setVisibility(View.VISIBLE);
                    tv_day.setBackgroundResource(R.mipmap.tv_signir_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_un_sign);
                    ivIcon.setImageResource(R.mipmap.mine_un_sign_in);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.grayLightColor));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.grayDirkColor));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.grayColor));
                } else if (position == 3) {
                    tv_day.setBackgroundResource(R.mipmap.tv_signied_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_sign);
                    ivIcon.setImageResource(R.mipmap.mine_sign_in);
                    ivSignIn.setVisibility(View.VISIBLE);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.white));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.white));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.white));
                }
            } else if (Double.parseDouble(onDay) == 5) {
                if (position < 4) {
                    ivSignIn.setVisibility(View.VISIBLE);
                    tv_day.setBackgroundResource(R.mipmap.tv_signir_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_un_sign);
                    ivIcon.setImageResource(R.mipmap.mine_un_sign_in);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.grayLightColor));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.grayDirkColor));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.grayColor));
                } else if (position == 4) {
                    tv_day.setBackgroundResource(R.mipmap.tv_signied_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_sign);
                    ivIcon.setImageResource(R.mipmap.mine_sign_in);
                    ivSignIn.setVisibility(View.VISIBLE);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.white));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.white));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.white));
                }
            } else if (Double.parseDouble(onDay) == 6) {
                if (position < 5) {
                    ivSignIn.setVisibility(View.VISIBLE);
                    tv_day.setBackgroundResource(R.mipmap.tv_signir_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_un_sign);
                    ivIcon.setImageResource(R.mipmap.mine_un_sign_in);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.grayLightColor));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.grayDirkColor));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.grayColor));
                } else if (position == 5) {
                    tv_day.setBackgroundResource(R.mipmap.tv_signied_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_sign);
                    ivIcon.setImageResource(R.mipmap.mine_sign_in);
                    ivSignIn.setVisibility(View.VISIBLE);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.white));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.white));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.white));
                }
            } else if (Double.parseDouble(onDay) == 7) {
                if (position < 6) {
                    ivSignIn.setVisibility(View.VISIBLE);
                    tv_day.setBackgroundResource(R.mipmap.tv_signir_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_un_sign);
                    ivIcon.setImageResource(R.mipmap.ic_gift);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.grayLightColor));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.grayDirkColor));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.grayColor));
                } else if (position == 6) {
                    tv_day.setBackgroundResource(R.mipmap.tv_signied_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_sign);
                    ivIcon.setImageResource(R.mipmap.ic_gift);
                    ivSignIn.setVisibility(View.VISIBLE);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.white));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.white));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.white));
                }
            }
        } else {//未签到
            if (Double.parseDouble(onDay) == 0) {
                if (position == 0) {
                    tv_day.setBackgroundResource(R.mipmap.tv_signied_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_sign);
                    ivIcon.setImageResource(R.mipmap.mine_sign_in);
                    ivSignIn.setVisibility(View.INVISIBLE);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.white));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.white));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.white));
                } else {
                    ivSignIn.setVisibility(View.INVISIBLE);
                    tv_day.setBackgroundResource(R.mipmap.tv_signir_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_un_sign);
                    ivIcon.setImageResource(R.mipmap.mine_un_sign_in);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.grayLightColor));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.grayDirkColor));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.grayColor));
                }
            } else if (Double.parseDouble(onDay) == 1) {
                if (position == 0) {
                    ivSignIn.setVisibility(View.VISIBLE);
                    tv_day.setBackgroundResource(R.mipmap.tv_signir_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_un_sign);
                    ivIcon.setImageResource(R.mipmap.mine_un_sign_in);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.grayLightColor));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.grayDirkColor));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.grayColor));
                } else if (position == 1) {
                    tv_day.setBackgroundResource(R.mipmap.tv_signied_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_sign);
                    ivIcon.setImageResource(R.mipmap.mine_sign_in);
                    ivSignIn.setVisibility(View.INVISIBLE);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.white));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.white));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.white));
                } else {
                    ivSignIn.setVisibility(View.INVISIBLE);
                    tv_day.setBackgroundResource(R.mipmap.tv_signir_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_un_sign);
                    ivIcon.setImageResource(R.mipmap.mine_un_sign_in);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.grayLightColor));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.grayDirkColor));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.grayColor));
                }
            } else if (Double.parseDouble(onDay) == 2) {
                if (position < 2) {
                    ivSignIn.setVisibility(View.VISIBLE);
                    tv_day.setBackgroundResource(R.mipmap.tv_signir_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_un_sign);
                    ivIcon.setImageResource(R.mipmap.mine_un_sign_in);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.grayLightColor));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.grayDirkColor));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.grayColor));
                } else if (position == 2) {
                    tv_day.setBackgroundResource(R.mipmap.tv_signied_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_sign);
                    ivIcon.setImageResource(R.mipmap.mine_sign_in);
                    ivSignIn.setVisibility(View.INVISIBLE);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.white));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.white));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.white));
                } else {
                    ivSignIn.setVisibility(View.INVISIBLE);
                    tv_day.setBackgroundResource(R.mipmap.tv_signir_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_un_sign);
                    ivIcon.setImageResource(R.mipmap.mine_un_sign_in);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.grayLightColor));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.grayDirkColor));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.grayColor));
                }
            } else if (Double.parseDouble(onDay) == 3) {
                if (position < 3) {
                    ivSignIn.setVisibility(View.VISIBLE);
                    tv_day.setBackgroundResource(R.mipmap.tv_signir_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_un_sign);
                    ivIcon.setImageResource(R.mipmap.mine_un_sign_in);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.grayLightColor));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.grayDirkColor));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.grayColor));
                } else if (position == 3) {

                    tv_day.setBackgroundResource(R.mipmap.tv_signied_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_sign);
                    ivIcon.setImageResource(R.mipmap.mine_sign_in);
                    ivSignIn.setVisibility(View.INVISIBLE);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.white));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.white));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.white));


                } else {
                    ivSignIn.setVisibility(View.INVISIBLE);
                    tv_day.setBackgroundResource(R.mipmap.tv_signir_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_un_sign);
                    ivIcon.setImageResource(R.mipmap.mine_un_sign_in);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.grayLightColor));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.grayDirkColor));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.grayColor));
                }
            } else if (Double.parseDouble(onDay) == 4) {
                if (position < 4) {
                    ivSignIn.setVisibility(View.VISIBLE);
                    tv_day.setBackgroundResource(R.mipmap.tv_signir_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_un_sign);
                    ivIcon.setImageResource(R.mipmap.mine_un_sign_in);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.grayLightColor));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.grayDirkColor));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.grayColor));
                } else if (position == 4) {

                    tv_day.setBackgroundResource(R.mipmap.tv_signied_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_sign);
                    ivIcon.setImageResource(R.mipmap.mine_sign_in);
                    ivSignIn.setVisibility(View.INVISIBLE);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.white));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.white));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.white));
                } else {
                    ivSignIn.setVisibility(View.INVISIBLE);
                    tv_day.setBackgroundResource(R.mipmap.tv_signir_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_un_sign);
                    ivIcon.setImageResource(R.mipmap.mine_un_sign_in);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.grayLightColor));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.grayDirkColor));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.grayColor));


                }
            } else if (Double.parseDouble(onDay) == 5) {
                if (position < 5) {
                    ivSignIn.setVisibility(View.VISIBLE);
                    tv_day.setBackgroundResource(R.mipmap.tv_signir_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_un_sign);
                    ivIcon.setImageResource(R.mipmap.mine_un_sign_in);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.grayLightColor));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.grayDirkColor));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.grayColor));
                } else if (position == 5) {
                    tv_day.setBackgroundResource(R.mipmap.tv_signied_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_sign);
                    ivIcon.setImageResource(R.mipmap.mine_sign_in);
                    ivSignIn.setVisibility(View.INVISIBLE);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.white));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.white));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.white));
                } else {
                    ivSignIn.setVisibility(View.INVISIBLE);
                    tv_day.setBackgroundResource(R.mipmap.tv_signir_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_un_sign);
                    ivIcon.setImageResource(R.mipmap.mine_un_sign_in);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.grayLightColor));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.grayDirkColor));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.grayColor));
                }
            } else if (Double.parseDouble(onDay) == 6) {
                if (position < 6) {
                    ivSignIn.setVisibility(View.VISIBLE);
                    tv_day.setBackgroundResource(R.mipmap.tv_signir_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_un_sign);
                    ivIcon.setImageResource(R.mipmap.ic_gift);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.grayLightColor));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.grayDirkColor));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.grayColor));
                } else if (position == 6) {
                    tv_day.setBackgroundResource(R.mipmap.tv_signied_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_sign);
                    ivIcon.setImageResource(R.mipmap.ic_gift);
                    ivSignIn.setVisibility(View.INVISIBLE);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.white));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.white));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.white));
                } else {
                    ivSignIn.setVisibility(View.INVISIBLE);
                    tv_day.setBackgroundResource(R.mipmap.tv_signir_bg);
                    back_sigin.setBackgroundResource(R.drawable.shape_un_sign);
                    ivIcon.setImageResource(R.mipmap.ic_gift);
                    tv_day.setTextColor(getContext().getResources().getColor(R.color.grayLightColor));
                    tv_add.setTextColor(getContext().getResources().getColor(R.color.grayDirkColor));
                    tvUnit.setTextColor(getContext().getResources().getColor(R.color.grayColor));
                }
            }
        }
    }
}
